#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QFileDialog>
#include <QTimer>
#include <QTime>
#include <QUrl>
#include <QMouseEvent>
#include "ui_MainWindow.h"
#include "EditExtractionsWindow.h"
#include "VideoManagerSingleton.h"
#include "OptionsWindow.h"
#include "Settings.h"

#define TEXT_TIME "--:--/--:--"

class MainWindow : public QMainWindow, private Ui::MainWindow{
    Q_OBJECT

    public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();
    int getVideoWidgetId();
    void eventuallyRestoreAfterCrash();
    void restoreAfterCrash();
    void setCrashed(bool crashed);
    bool hasCrashed();

    public slots:
    void openVideo();
    void openVideo(QString fileName);
    void updateAfterOpeningVideo();
    void eventuallyReplayVideo();
    void _ajustVideoFromUserInterfaceChoice();
    void addSubtitle(QString strFileName, int idSubtitleTrack);
    void playOrPause();
    void stop();
    void updateReadingSliderAndTime();
    void updateReadingSlider();
    void updateTime();
    void seek(int position);
    void setVolume(int position);
    void addExtraction();
    void showEditExtractionsWindow();
    void loadSettings();
    void showNormalOrMaximized();
    void setPlayIcon();
    void setPauseIcon();
    void closeEvent(QCloseEvent* ce);

    signals:
    void play();
    void pause();


    private:
    QString lastOpenedFileName;
    bool hasBeenStopped;
    double realReadingSliderValue;
    EditExtractionsWindow *editExtractionsWindow;
    VideoManagerSingleton *videoManager;
    OptionsWindow *optionsWindow;
    QIcon *playIcon;
    QIcon *pauseIcon;
    QTimer *timer;
    QLabel *readingTimeLabel;
    bool isMaximized;
    Settings settings;
    void _pause();
    void _play();
    void _updateBoundariesSlider();
    void _initVariables();
    void _initWindow();
    void _initPlayPauseIcons();
    void _initTimeLabel();
    void _initSliderTimer();
    void _initWindows();
    void _initMlt();
    void _ajustFromSettings();
    void _connectSlots();
    void dragEnterEvent(QDragEnterEvent *event);
    void dropEvent(QDropEvent *event);

};

#endif // MAINWINDOW_H
